package n3267;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static String[] dict=new String[600];
	
	
	static String mess;
	
	static int W,L;
	
	
	static void solve()
	{
		int dp[]=new int[L+1];
		for(int i=0;i<L+1;i++)dp[i]=i;
		for(int i=1;i<L+1;i++)
		{
			for(int j=0;j<W;j++)
			{
				int lk=0,lj=i-1,cnt=0;
				while(lk<dict[j].length()&&lj<L)
				{
					if(dict[j].charAt(lk)==mess.charAt(lj))
					{
						lk++;
						lj++;
					}else{
						cnt++;
						lj++;
					}
				}
				if(lk==dict[j].length())
				{
					if(dp[i-1]+cnt<dp[lj]){
						dp[lj]=dp[i-1]+cnt;
//						for(int p=lj+1;p<L+1;p++)
//						{
//							if(dp[lj]+p-lj<dp[p])dp[p]=dp[lj]+p-lj;
//						}
					}
				}
				else{
					if(dp[i-1]+lj-i+1<dp[lj])dp[lj]=dp[i-1]+lj-i+1;
				}
			}
			
		}
		
		System.out.println(dp[L]);
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(bf.readLine());
		W=Integer.parseInt(st.nextToken());
		L=Integer.parseInt(st.nextToken());
		mess=bf.readLine();
		for(int i=0;i<W;i++)dict[i]=bf.readLine();
		solve();
	}

}
